// 部署合约到区块链
let {bytecode,interface} = require('./compile');

// 引入web3
let Web3 = require('web3');
// 实例化web3
let web3 = new Web3;
// console.log(web3.version);
// 设置网络
web3.setProvider('http://localhost:7545');
// console.log('addr:---',web3.currentProvider);
const accout = '0x43B05ee522bDBcb6c0bC0174C6439D257Af1D86f';

// 实例化合约
let contract = new web3.eth.Contract(JSON.parse(interface));

// 拼接bytecode
contract.deploy({
    data:bytecode,
    arguments:['hello world'],
}).send({
    from:accout,
    // gasPrice:1,
    gas:'300000',
}).then(res=>{
    console.log('===结果===',res.options.address);
});

